#!/bin/bash

INPUTFILE="@CMAKE_SOURCE_DIR@/examples/MQ/serialization/data_io/inputEx.root"
OUTPUTFILE="@CMAKE_SOURCE_DIR@/examples/MQ/serialization/data_io/outputEx2.root"

########################## start SAMPLER
SAMPLER="ex-serialization2-sampler"
SAMPLER+=" --id sampler1"
SAMPLER+=" --channel-config name=data1,type=push,method=bind,address=tcp://localhost:5565"
SAMPLER+=" --input-file $INPUTFILE"
xterm -geometry 100x27+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/serialization/$SAMPLER &

########################## start three PROCESSORs
PROCESSOR1="ex-serialization2-processor"
PROCESSOR1+=" --id processor1"
PROCESSOR1+=" --channel-config name=data1,type=pull,method=connect,address=tcp://localhost:5565"
PROCESSOR1+="                  name=data2,type=push,method=connect,address=tcp://localhost:5570"
xterm -geometry 100x27+800+0 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/serialization/$PROCESSOR1 &

PROCESSOR2="ex-serialization2-processor"
PROCESSOR2+=" --id processor2"
PROCESSOR2+=" --channel-config name=data1,type=pull,method=connect,address=tcp://localhost:5565"
PROCESSOR2+="                  name=data2,type=push,method=connect,address=tcp://localhost:5570"
xterm -geometry 100x27+800+500 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/serialization/$PROCESSOR2 &

PROCESSOR3="ex-serialization2-processor"
PROCESSOR3+=" --id processor3"
PROCESSOR3+=" --channel-config name=data1,type=pull,method=connect,address=tcp://localhost:5565"
PROCESSOR3+="                  name=data2,type=push,method=connect,address=tcp://localhost:5570"
xterm -geometry 100x27+800+1000 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/serialization/$PROCESSOR3 &

########################## start FILESINK
FILESINK="ex-serialization2-sink"
FILESINK+=" --id sink1"
FILESINK+=" --channel-config name=data2,type=pull,method=bind,address=tcp://localhost:5570"
FILESINK+=" --output-file $OUTPUTFILE"
xterm +aw -geometry 100x27+0+1000 -hold -e @CMAKE_BINARY_DIR@/bin/examples/MQ/serialization/$FILESINK &
